﻿using Sustainalytics.Common.Hosting;
using Sustainalytics.Utils.Serilog;
using Sustainalytics.WebApiHosting;
using System;

namespace Sustainalytics.Controversies.Service.Infrastructure
{
    class ControversiesServiceApplication : ServiceApplication
    {
        public ControversiesServiceApplication() : base()
        {

        }

        public ControversiesServiceApplication(IBasicLogger logger) : base(logger)
        {

        }
        protected override void AddStartupServices()
        {
            RegisterService(new WebApiServiceDefinition<Startup>(HostConfig.GetHostUrl(), "controversiesService"));
        }

        protected override bool HandleStartException(System.Exception e)
        {
            ControversiesServiceSerilog.Log.ApplicationStartError(e);
            return false;
        }

        protected override bool HandleStopException(System.Exception e)
        {
            ControversiesServiceSerilog.Log.ApplicationStopError(e);
            return false;
        }

        protected override void OnUnhandledDomainException(System.Exception e)
        {
            ControversiesServiceSerilog.Log.OnUnhandledDomainException(e);
        }
    }
}
